<template>
	<view>
		<view class="today-list">
			<view class="list flex between align" v-for="(item,index) in list" :key="index">
				<view class="list-left flex align">
					<image :src="item.prize_image"></image>
					<view>
						<view>券码：{{item.order_no}}</view>
						<view>奖品：{{item.prize_name}}</view>
						<view class="time">核销时间：{{item.verification_time}}</view>
					</view>
				</view>
			</view>
			<uni-load-more :status="status" v-if="!empty" :content-text="loadText"></uni-load-more>
			<xw-empty :isShow="empty" text="暂无数据" textColor="#777777"></xw-empty>
		</view>
	</view>
</template>

<script>
	import {
		managerMyList
	} from '@/api/apiData.js';
	export default {
		data() {
			return {
				totalPage: 1,
				page: 0,
				offset: 10,
				list: [],
				scrollTop: 0,
				empty: false,
				loadText: {
					loadmore: '点击或上拉加载更多',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				status: 'loadmore',
			};
		},
		mounted() {
			this.getlist()
		},
		methods: {
			async getlist() {
				const that = this;
				const {
					totalPage,
					page,
					offset,
					list,
				} = that;
				let obj = {
					size: offset,
					page: page + 1,
				};
				that.status = 'loading';
				if (totalPage > page) {
					let result = await managerMyList(obj);
					if (result.code == 1) {
						that.page = page + 1;
						if (result.data.total == 0) {
							that.empty = true;
							that.status = 'nomore';
							return;
						}
						that.empty = false;
						setTimeout(() => {
							that.status = 'loadmore';
						}, 500);
						that.list = list.concat(result.data.list);
						that.totalPage = Math.ceil(result.data.total / offset);
					}
				} else {
					setTimeout(() => {
						that.status = 'nomore';
					}, 500);
				}
			},
		},
		onPageScroll(e) {
			const that = this;
			that.scrollTop = e.scrollTop;
		},
		onReachBottom() {
			const that = this;
			that.getlist();
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: #F7F6F9;
	}

	.list {
		background: white;
		border-right: 20rpx;
		padding: 24rpx 36rpx;
		margin-top: 24rpx;
	}

	.list-left {
		font-size: 22rpx;
		color: #333333;
		font-weight: bold;
	}

	.list-left image {
		width: 86rpx;
		height: 85rpx;
		margin-right: 20rpx;
	}

	.time {
		color: #C0C0C0;
		font-size: 19rpx;
		font-weight: normal;
		margin-top: 10rpx;
	}

	.list-ri {
		color: #FF2937;
		font-size: 26rpx;
		font-weight: bold;
	}
</style>